{template 'header'}
<link rel="stylesheet" href="{$siteRoot}addons/{$modular_name}/template/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="{$siteRoot}addons/{$modular_name}/template/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/lang/zh-CN.js"></script>
<script charset="utf-8" src="{$siteRoot}addons/{$modular_name}/template/kindeditor/plugins/code/prettify.js"></script>
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('goods');}">商品管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('goods', array('op' => 'addshow'));}">添加商品</a></li>
    <li class=""><a href="{php echo $this->createWeburl('category')}">商品分类管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('category', array('op' => 'addshow'));}">添加分类</a></li>
</ul>
<form action="" method="post" class="form-horizontal" id="myform" role="form" enctype="multipart/form-data">
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">分类:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <select name="category_id" class="form-control">
                {loop $category $item}
                <option value="{$item['id']}" {if $item['id'] == $goods['category_id']} selected {/if}>{$item['category_name']}</option>
                {/loop}
            </select>
        </div>
    </div>



    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">商品名称:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="goods_name" placeholder="商品名称" value="{$goods['goods_name']}" type="text">
        </div>
    </div>
  <!--  <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">分享标题:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="share_title" placeholder="分享标题" value="{$goods['share_title']}" type="text">
        </div>
    </div>-->
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">商品分类</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="type" value="1" {if $goods['type'] == 1 || $goods['type'] == ''} checked {/if} /> 实物
            </label>
            <label class="radio-inline">
                <input type="radio" name="type" value="2" {if $goods['type'] == 2} checked {/if}/>红包
            </label>
            {if $isSupportQQ ==1}
                {if $isPopularitye}
                    <label class="radio-inline">
                        <input type="radio" name="type" value="3" {if $goods['type'] == 3} checked {/if}/>点赞
                    </label>
                {/if}
            {/if}
        </div>
    </div>

    {if $isSupportQQ ==1}
        {if $isPopularitye}
            <div class="form-group" id="fabulous"  {if $goods['type'] != 3 } style="display: none" {/if} >
            <label class="col-xs-12 col-sm-3 col-md-1 control-label">点赞商品编号:</label>
            <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
                <input class="form-control" name="fabulous" placeholder="点赞商品编号" value="{$goods['fabulous']}" type="text">
            </div>
            </div>
        {/if}

        {if $isQqhome}
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否首頁</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="is_home" value="1" {if $goods['is_home'] == 1 || $goods['is_home'] == ''} checked {/if} /> 非首頁
            </label>
            <label class="radio-inline">
                <input type="radio" name="is_home" value="2" {if $goods['is_home'] == 2} checked {/if}/>首頁
            </label>
        </div>
    </div>

    {/if}
    {/if}


    <div class="form-group" id="bag_money"  {if $goods['type'] != 2 } style="display: none" {/if} >
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">红包金额:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="bag_money" placeholder="红包金额" value="{$goods['bag_money']}" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">兑换方式</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="exchange_type" value="1" {if $goods['exchange_type'] == 1 || $goods['exchange_type'] == ''} checked {/if} /> 金币
            </label>
            <label class="radio-inline">
                <input type="radio" name="exchange_type" value="2" {if $goods['exchange_type'] == 2} checked {/if}/>金币加钱
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">兑换限制</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="allow_type" value="1" {if $goods['allow_type'] == 1 || $goods['allow_type'] == ''} checked {/if} /> 每人总计
            </label>
            <label class="radio-inline">
                <input type="radio" name="allow_type" value="2" {if $goods['allow_type'] == 2} checked {/if}/>每人每天
            </label>
        </div>
    </div>


    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">原价:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="original_price" placeholder="原价" value="{$goods['original_price']}" type="text">
        </div>
    </div>
    <div class="form-group" id="money" {if $goods['exchange_type'] != 2 } style="display: none" {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">兑换需要金额:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="money" placeholder="兑换需要金额" value="{$goods['money']}" type="text">
        </div>
    </div>

    <div class="form-group" id="exchange_type_money">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label" >兑换需要的金币数量:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="exchange_number" placeholder="兑换需要的金币数量" value="{$goods['exchange_number']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">库存:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="inventory" placeholder="库存" value="{$goods['inventory']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">每人允许兑换的数量:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="allow_number" placeholder="每人允许兑换的数量0无限兑换" value="{$goods['allow_number']}" type="text">
        </div>
    </div>


    <div class="form-group" id="ling-1">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">图片:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            {php echo tpl_form_field_image('cover_image',  $goods['cover_image'],  tomedia($goods['cover_image']));}
            <small style="color: red">图片大小建议为 : 170 * 170</small>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">详情:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            {php echo tpl_form_field_multi_image('image',$goods['image']);}
            <small style="color: red">图片大小建议为: 410 * 400</small>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否包邮</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="is_free" value="1" {if $goods['is_free'] ==1 || $goods['is_free'] == ''} checked {/if} /> 包邮
            </label>
            <label class="radio-inline">
                <input type="radio" name="is_free" value="2" {if $goods['is_free'] ==2} checked {/if}/>不包邮
            </label>
        </div>
    </div>

    <div class="form-group" id="is_free_money" {if $goods['is_free'] != 2 } style="display: none" {/if} >
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">邮费:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="free" placeholder="邮费" value="{$goods['free']}" type="text">
        </div>
    </div>

    <div class="form-group" id="compiler" >
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">商品描述:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12" style="padding-top:8px;">
            <textarea name="introduce" style="width:1000px;height:400px;visibility:hidden;">{$goods['introduce']}</textarea>
        </div>
        <script>
            KindEditor.ready(function(K) {
                htmlEditor = K.create(
                    'textarea[name="introduce"]',
                    {
                        uploadJson : "{php echo $this->createWebUrl('editorUpload');}",
                        fileManagerJson : '{$siteRoot}addons/{$modular_name}/template/kindeditor/php/file_manager_json.php',
                        height : 300,
                        width : '90%',
                        resizeType : 0,//1
                        allowPreviewEmoticons : true,
                        allowImageUpload : true,
                        urlType:'domain',
                        formatUploadUrl:false
                    });
            });
        </script>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">上下架</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="status" value="1" {if $goods['status'] ==1 || $goods['status'] == ''} checked {/if} /> 上架
            </label>
            <label class="radio-inline">
                <input type="radio" name="status" value="2" {if $goods['status'] ==2} checked {/if}/>下架
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">顺序:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="sort" placeholder="顺序" value="{$goods['sort']}" type="text">
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label"></label>
        <div class="" >
            <input type="hidden" name="op" value="{php echo $id ? 'edit' : 'add'}">
            <input type="hidden" name="id" value="{$id}">
            <input type="submit" name="submit" id="submit" value="{php echo $id ? '修改' : '新增'}" class="btn btn-primary">
        </div>
    </div>
</form>
{template 'footer'}


<script>
    $(function () {
        $("input[name='exchange_type']").click(function () {
            if ( $(this).val() == 1) {
                $('#exchange_type_money').show();
                $('#money').hide();
            }  else {
                $('#exchange_type_money').show();
                $('#money').show();
            }
        });


        $("input[name='is_free']").click(function () {
            if ( $(this).val() == 1) {
                $('#is_free_money').hide();
            }  else {
                $('#is_free_money').show();
            }
        });

        $("input[name='type']").click(function () {
            if ( $(this).val() == 1) {
                $('#bag_money').hide();
                $('#fabulous').hide();
            }  else if($(this).val() ==2){
                $('#bag_money').show();
                $('#fabulous').hide();
            } else {
                $('#bag_money').hide();
                $('#fabulous').show();
            }
        });

    })


</script>